<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Loads C declarations from a C header file</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ffi.isnull.html">« FFI::isNull</a></li>
      <li style="float: right;"><a href="ffi.memcmp.html">FFI::memcmp »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.ffi.html">FFI</a></li>
    <li>Loads C declarations from a C header file</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="ffi.load" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">FFI::load</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">FFI::load</span> &mdash; <span class="dc-title">Loads C declarations from a C header file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ffi.load-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>FFI::load</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>): <span class="type"><span class="type">?</span><span class="type"><a href="class.ffi.html" class="type FFI">FFI</a></span></span></div>

  <p class="para rdfs-comment">
   Loads C declarations from a C header file. It is possible to specify shared libraries that should be loaded,
   using special <code class="literal">FFI_LIB</code> defines in the loaded C header file.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ffi.load-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">filename</code></dt>

    <dd>

     <p class="para">
      The name of a C header file.
     </p>
     <p class="para">
      C preprocessor directives are not supported, i.e. <code class="literal">#include</code>,
      <code class="literal">#define</code> and CPP macros do not work, except for special cases
      listed below.
     </p>
     <p class="para">
      The header file <em class="emphasis">should</em> contain a <code class="literal">#define</code> statement for the
      <code class="literal">FFI_SCOPE</code> variable, e.g.: <code class="code">#define FFI_SCOPE &quot;MYLIB&quot;</code>.
      Refer to the <a href="class.ffi.html#ffi.intro" class="link">class introduction</a> for details.
     </p>
     <p class="para">
      The header file <em class="emphasis">may</em> contain a <code class="literal">#define</code> statement for the
      <code class="literal">FFI_LIB</code> variable to specify the library it exposes. If it is
      a system library only the file name is required, e.g.: <code class="code">#define FFI_LIB
      &quot;libc.so.6&quot;</code>.  If it is a custom library, a relative path is required,
      e.g.: <code class="code">#define FFI_LIB &quot;./mylib.so&quot;</code>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-ffi.load-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the freshly created <span class="classname"><a href="class.ffi.html" class="classname">FFI</a></span> object, or <strong><code>null</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-ffi.load-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="ffi.scope.html" class="methodname" rel="rdfs-seeAlso">FFI::scope()</a> - Instantiates an FFI object with C declarations parsed during preloading</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>